/** 
* All Rights Reserved , Copyright (C) 2020 , 青岛鼎信通讯股份有限公司
* 
* PmCommunicationManageService
* 沟通管理
* 
* 修改纪录
* 2020-05-22 版本：1.0 sunxl 创建。
* @version 版本：1.0
* @author 作者：sunxl
* 创建日期：2020-05-22
*/
package com.topscomm.pm.service.impl;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.topscomm.pm.service.IPmCommunicationManageService;
import com.topscomm.pm.service.impl.auto.PmCommunicationManageServiceAuto;
import com.topscomm.basic.BasicEntity;
import com.topscomm.basic.util.PrimaryKeyUtil;
import com.topscomm.pm.pojo.PmCommunicationManageEntity;

@Service(value = "pmCommunicationManageService")
@Scope(value = "singleton")
public class PmCommunicationManageService extends PmCommunicationManageServiceAuto implements IPmCommunicationManageService {
	/**
	 * @author: sunxl
	 * @date: 2020-05-22
	 * @param entity
	 * @throws ServiceException
	 * @description:单号生成
	 * @modify:
	 */
	@Override
	protected void beforeInsert(BasicEntity entity){		
		super.beforeInsert(entity);
		if (entity.getId() <= 0) {// 赋值Id和单号
			long[] arrayId = PrimaryKeyUtil.GeneIDs(entity.getTableName(), 1);
			entity.setId(arrayId[0]);
			String docNo = String.valueOf(arrayId[0]);
			docNo = docNo.substring(0, 6) + docNo.substring(9);
			entity.setValue(PmCommunicationManageEntity.FieldDocno, docNo);
		}
	}
}
